package com.onepower.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.onepower.core.domain.request.MatchAdminForm;
import com.onepower.core.domain.response.MatchAdminInfo;
import com.onepower.core.modules.service.ISysUserService;
import com.onepower.core.result.CommonResult;
import com.onepower.core.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/match/admin")
public class MatchAdminController {

    @Autowired
    private ISysUserService sysUserService;

    @RequestMapping(value = "list", method = RequestMethod.GET)
    public CommonResult list(@RequestParam(value = "matchId", required = false, defaultValue = "0") Integer matchId,
                             @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                             @RequestParam(value = "pageSize", required = false, defaultValue = "20") int pageSize) {
        Page<MatchAdminInfo> matchAdminList = sysUserService.getMatchAdminList(new Page<>(pageNum, pageSize), matchId);
        return ResultUtils.ok(matchAdminList);
    }

    @RequestMapping(value = "save", method = RequestMethod.POST)
    public CommonResult save(@RequestBody MatchAdminForm matchAdminForm) {
        sysUserService.saveMatchAdmin(matchAdminForm);
        return ResultUtils.ok();
    }
}
